<!DOCTYPE html>
<html>
<head>
    {include file="public/header" /}
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layuimini-main">

        <form class="layui-form" action="">
            <div class="layui-form-item" >
                <label class="layui-form-label">金币比例</label>
                <div class="layui-input-inline">
                    <input type="number" name="ratio" placeholder="请输入金币比例"  autocomplete="off" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item" >
                <label class="layui-form-label">发送日期</label>
                <div class="layui-input-inline">
                    <input type="text" name="apply_time" id="apply_time" value="" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input iwidth" >
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="add">立即创建</button>
                </div>
            </div>
        </form>

    </div>
</div>

{include file="public/footer" /}

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'laydate','wangEditor'], function () {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate,
            $ = layui.jquery;
        $(this).removeAttr("lay-key");//时间框一点就消失处理
        // 上架开始日期
        var insShelf = laydate.render({
            elem: '#apply_time'
            , min: 0
            , trigger : 'click'//时间框一点就消失处理
            , calendar: true
            , type: 'date'
            , done: function (value, date) {

            }
        });
        //监听提交修改
        form.on('submit(add)', function (data) {
            let  postdata =data.field
            $.ajax({
                url: '/admin/Ratio/ratio_add?action=ajax',
                type: 'post',
                dataType: 'json',
                data: postdata,
                success: function (res) {
                    if (res.status == true) {    // 获得frame索引
                        parent.layer.msg("操作成功!",
                            {
                                icon:1,
                                time: 1000
                            },
                            function () {
                            //重新加载父页面
                                parent.location.reload();
                        });
                        return;
                    } else{
                        layer.msg(res.msg,{ icon:5,
                            time: 1000});
                    }
                },
                error: function () {
                    layer.msg("报错了");
                }
            });
            return false;
        });
    });
</script>
</body>
</html>